package com.cbs.android.widget.attextview.sample;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextPaint;
import android.view.View;

import com.cbs.android.component.log.L;
import com.cbs.android.widget.attextview.AtTextView;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = MainActivity.class.getName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AtTextView atTextView = (AtTextView) findViewById(R.id.textview);
        atTextView.setLinkStyle(new AtTextView.LinkStyle() {
            @Override
            public void updateDrawState(TextPaint ds) {
                ds.setColor(Color.BLUE);
                ds.setUnderlineText(true);
            }

            @Override
            public int getBackgroundColor() {
                return Color.GRAY;
            }
        });
        String content = "@abc测试方法将违反 i  论文@分解为 i 饿@ @abc测试方法将违反 i  论文@分解为 i 饿@ @abc测试方法将违反 i  论文@分解为 i 饿@ ";
//        atTextView.setText(content);
        atTextView.loadContent(content);
        atTextView.setOnClickListener(new AtTextView.OnClickListener() {
            @Override
            public void onClick(View v) {
                L.e(TAG, "clicked");
            }

            @Override
            public void onLink(View v, String href) {
                L.e(TAG, "href: " + href);
            }
        });
    }
}
